package com.center.dialog;


import android.view.View;

import com.blankj.utilcode.util.AppUtils;
import com.blankj.utilcode.util.ToastUtils;
import com.center.R;
import com.center.databinding.SystemDialogBinding;
import com.center.model.ViewModelQQLogin;
import com.tencent.tauth.Tencent;

import base.QDialogFragment;
import constant.AppConstants;

public class SystemDialog extends QDialogFragment<SystemDialogBinding> {
    private static Tencent mTencent;
    private ViewModelQQLogin viewModelQQLogin;
    @Override
    public int getLayoutRes() {
        return R.layout.system_dialog;
    }

    @Override
    public void initView() {
        viewModelQQLogin = ViewModelQQLogin.getInstance();
        Tencent.setIsPermissionGranted(true);
        mTencent = Tencent.createInstance(AppConstants.APP_ID, getActivity());
    }

    @Override
    public void initData() {
        binding.tvVersion.setText("APP版本号:" + AppUtils.getAppVersionName());
    }

    @Override
    public void initListener() {
        binding.tvQuit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mTencent.logout(getContext());
                viewModelQQLogin.getAvatarUrl().setValue(null);
                viewModelQQLogin.getQQName().setValue(null);
                ToastUtils.showLong("退出登录");
            }
        });


        binding.ivClose.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }




    @Override
    public void networkMessage() {

    }
}
